<?php
include('functions.php');

if(isset($_COOKIE['loginInfo'])) {

	$json = curl("http://www.djmaxcn.com/crew/GetCrewRaceCurrent.asp?p=1");
    $rank = json_decode($json);
    unset($json);

    if($rank->DATA->ROW === 0) exit('发生错误, 请返回!');

    getHead('战队周排名');

    echo "<p style='color: #6683d6;'>第{$rank->DATA->RACEROUND}次（{$rank->DATA->SDATE}——{$rank->DATA->EDATE}）</p>";

    echo '<table width="100%" border="1" style="text-align:center;"><tr><th>排名</th><th>战队名</th><th>点数</th></tr>';

    foreach ($rank->DATA->RECORD as $rec) {
    	echo <<<EOT
<tr style="line-height:2em;">
	<td>{$rec->RANK}</td>
	<td>{$rec->CREWNAME}</td>
	<td>{$rec->CREWPOINT} EXP</td>
</tr>
EOT;
		if ($rec->DJNAME) {
			$disk = array();
			@$disk[] = array_shift(explode('_', $rec->DISK1));
			@$disk[] = array_shift(explode('_', $rec->DISK2));
			@$disk[] = array_shift(explode('_', $rec->DISK3));
			echo <<<EOT
<tr style="background-color:#eee;color:#555;line-height:2em;">
	<td style="border-right:none;">DJ: <span style='color: #6683d6;'>{$rec->DJNAME}</span></td>
	<td style="border-right:none;border-left:none;">Disk: <span style='color: #6683d6;'>{$disk[0]}</span>, <span style='color: #6683d6;'>{$disk[1]}</span>, <span style='color: #6683d6;'>{$disk[2]}</span></td>
	<td style="border-left:none;">Win/Play: <span style='color: #6683d6;'>{$rec->CREWWINCOUNT}</span>/<span style='color: #6683d6;'>{$rec->CREWPLAYCOUNT}</span></td>
</tr>
EOT;
		}
    }

    echo '</table>';

    getFoot();

} else {
	getHead('战队周排名');
	echo '请<a href="login.php">登录</a>';
	getFoot(false);
}



?>